////////////////////////////////////////////////////////////////////////////////
//
//  FLYING KIWI BV
//  Copyright 2010 Flying Kiwi BV
//  All Rights Reserved.
//
//  NOTICE: Flying Kiwi permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
package plantool.modules.calendar.display {
	//--------------------------------------------------------------------------
	//  Imports
	//--------------------------------------------------------------------------
	import com.adobe.utils.DateUtil;
	
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormatAlign;
	
	import kiwi.components.DragObject;
	import kiwi.components.IDropTarget;
	
	import plantool.core.CoreDisplayObject;
	import plantool.helpers.TextFieldHelper;
	import plantool.modules.users.Users;
	
	
	//--------------------------------------------------------------------------
	//  [Metadata (Events, Style, Effects etc)]
	//--------------------------------------------------------------------------
	
	//--------------------------------------------------------------------------
	//  Class declaration
	//--------------------------------------------------------------------------
	public class CalendarDay extends CoreDisplayObject implements IDropTarget {
		//--------------------------------------------------------------------------
		//Class constants
		//--------------------------------------------------------------------------
		
		//--------------------------------------------------------------------------
		//Class variables
		//--------------------------------------------------------------------------
		private var _date:Date 		= null;
		private var _tf:TextField 	= null;
		
		//--------------------------------------------------------------------------
		//Class properties
		//--------------------------------------------------------------------------
		public function get date():Date { return _date; }
		public function set date(value:Date):void { _date = value; invalidate(); }
		
		//--------------------------------------------------------------------------
		//Constructor and Destructor
		//--------------------------------------------------------------------------
		public function CalendarDay(date:Date) {
			super();
			
			_date = date;
		}
		
		//--------------------------------------------------------------------------
		//Class methods
		//--------------------------------------------------------------------------
		protected override function init():void {
			_tf 		= TextFieldHelper.createTitleTf(TextFieldAutoSize.LEFT, TextFormatAlign.LEFT, false, false, 0);
			_tf.width	= 162;
			_tf.text	= _date.toDateString();
			addChild(_tf);
		}
		
		public override function draw():void {
			_tf.text	= _date.toDateString();
		}
		
		public function dragObjectOver(target:DragObject):void {
			_tf.textColor = 0xFF6600;
		}
		
		public function dragObjectOut(target:DragObject):void {
			_tf.textColor = 0;
		}
	}
}